package com.jycrm.webservice.cust;


import javax.xml.rpc.ServiceException;
import org.springframework.remoting.jaxrpc.ServletEndpointSupport;
import com.jycrm.domain.cust.CrmCustomers;
import com.jycrm.domain.user.CrmUser;
import com.jycrm.service.cust.ICustService;
import com.jycrm.service.system.user.IUserService;

public class ResetPWDServiceEndpoint extends ServletEndpointSupport implements
		IResetPWDService {
	private ICustService custService;
	private IUserService useService;
	protected void onInit() throws ServiceException {
		super.onInit();
		 custService = (ICustService)getApplicationContext().getBean("custService");
		 useService = (IUserService)getApplicationContext().getBean("userService");
	}

	public boolean resetPasswd(String legendId,Long userId,String passWD,
			Long custId,String custPassWd){
		CrmCustomers cust = custService.getCustomerById(custId.toString());
		CrmUser user = useService.getUserById(userId);
		cust.setTaPassword(custPassWd);

    	try{
    		custService.updateCustomers(cust,user,"ip");
    	}catch (Exception ex){
    		ex.printStackTrace();
    		return false;
    	}
		return true;
	}

}
